/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IMAGEKNIFEC_IMAGEKNIFE_H
#define IMAGEKNIFEC_IMAGEKNIFE_H

#include "imageknife_request.h"
#include "cache_key_generator.h"
#include <future>
#include "imageknife_node.h"

namespace ImageKnifeC {
class ImageKnife {
public:
    static ImageKnife &GetInstance();

    virtual void InitImageKnifeArkTs(napi_env env, napi_value &exports) = 0;
    virtual void CancelRequest(std::shared_ptr<ImageKnifeRequest> request) = 0;
    virtual void InitFileCache(std::string, size_t size, size_t memory, std::string path) = 0;
    virtual void SetDefaultImageKnifeLoader(std::shared_ptr<ImageKnifeLoader> imageLoader) = 0;

    virtual void SetMaxRequests(int concurrency) = 0;
    virtual void SetCacheKeyGenerator(CacheKeyGenerator *keyPtr) = 0;
    virtual CacheKeyGenerator *GetCacheKeyGenerator() const = 0;
    virtual ~ImageKnife() = default;
    virtual std::shared_future<std::string> InitFileCacheAsync(std::string cachePath, size_t size, size_t memory,
                                                               std::string path) = 0;
    virtual std::shared_ptr<ImageKnifeRequest> Preload(std::shared_ptr<ImageKnifeOption> imageKnifeOption) = 0;

    virtual int64_t GetCacheLimitSize(CacheStrategy cacheStrategy) = 0;
    virtual int64_t GetCurrentCacheNum(CacheStrategy cacheStrategy) = 0;
    virtual int64_t GetCurrentCacheSize(CacheStrategy cacheStrategy) = 0;

    virtual std::shared_future<bool> RemoveFileAsync(std::string &url) = 0;
    virtual std::shared_future<bool> RemoveFileAsync(std::shared_ptr<ImageKnifeOption> option) = 0;
    virtual std::shared_future<bool> RemoveAllFileAsync(void) = 0; 
    virtual void RemoveAllMemoryCache() = 0;
    virtual bool RemoveMemoryCache(std::string url) = 0;
    virtual bool RemoveMemoryCache(std::shared_ptr<ImageKnifeOption> imageKnifeOption) = 0;
};

}

#endif // IMAGEKNIFEC_IMAGEKNIFE_H
